public class PalindromeCreator {

    public static String makeSmallestPalindrome(String s) {
        int len = s.length();
        int i = 0;
    
        while (i < len && s.charAt(i) == s.charAt(len - 1 - i)) {
            i++;
        }

        if (i == len) {
            return s;
        }
        
        String nonPalindromePart = s.substring(i, len - i);
        String reversedNonPalindromePart = new StringBuilder(nonPalindromePart).reverse().toString();
        
        return s + reversedNonPalindromePart;
    }

    public static void main(String[] args) {
        String testString = "abcd";
        String palindrome = makeSmallestPalindrome(testString);
        System.out.println(palindrome); // 输出: abcdcba
    }
}